package cz.khfotbal.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cz.khfotbal.dao.CompetionDao;
import cz.khfotbal.dao.SeasonCompetionDao;
import cz.khfotbal.domain.Competion;
import cz.khfotbal.domain.Season;
import cz.khfotbal.domain.SeasonCompetion;
import cz.khfotbal.service.CompetionService;

@Service
public class CompetionServiceImpl implements CompetionService {

	@Autowired
	private CompetionDao competionDao;

	@Autowired
	private SeasonCompetionDao seasonCompetionDao;

	public List<Competion> getCompetionsBySeason(Season season) {
		List<Competion> cList = new ArrayList<Competion>();
		List<SeasonCompetion> scList = seasonCompetionDao
				.findAllSeasonComptionsBySeasonId(season.getId());
		for (SeasonCompetion sc : scList) {
			cList.add(sc.getCompetion());
		}
		return cList;
	}

	public List<Competion> getAllCompetions() {
		List<Competion> cList = competionDao.findAllCompetions();
		return cList;
	}
	
	public Competion getCompetionById(int id){
		return competionDao.findCompetionById(id);
	}
}
